using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
    #region Employee

    /// <summary>
    /// Employee object for NHibernate mapped table 'Employee'.
    /// </summary>
    [Serializable]
    public class Employee : System.IComparable
    {
        #region Member Variables

        protected string _id;
        protected string _nameEN;
        protected string _nameCN;
        protected string _nameChinese;
        protected string _title;
        protected string _officePhone;
        protected string _email;
        protected string _mobile;
        protected bool _isEnabled;
        protected bool _isActived;
        protected string _nTAccount;
        protected Employee _reportTo;
        protected IList _reportToEmployees;
        protected Department _department;
        protected IList _delegateUserUserRoles;
        protected IList _userRoles;
        protected IList _agreements;
        protected IList _employeeIdALAttendees;
        protected IList _operationLogs;
        protected IList _requesterNoApplications;
        protected IList _someoneElseNoApplications;
        protected IList _advancedSearches;
        protected IList _actionOwnerActionPoints;
        protected IList _myBackupActionLogs;
        protected IList _flowMembers;
        protected IList _aPPartners;
        protected IList _departmentHeadDepartments;
        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public Employee() { }

        public Employee(string nameEN, string nameCN, string nameChinese, string title, string officePhone, string email, bool isEnabled, bool isActived, string nTAccount, Employee reportTo, Department department, string mobile)
        {
            this._nameEN = nameEN;
            this._nameCN = nameCN;
            this._nameChinese = nameChinese;
            this._title = title;
            this._officePhone = officePhone;
            this._email = email;
            this._mobile = mobile;
            this._isEnabled = isEnabled;
            this._isActived = isActived;
            this._nTAccount = nTAccount;
            this._reportTo = reportTo;
            this._department = department;
        }

        #endregion

        #region Public Properties

        public string Id
        {
            get { return _id; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Id", value, value.ToString());
                _id = value;
            }
        }

        public string NameEN
        {
            get { return _nameEN; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for NameEN", value, value.ToString());
                _nameEN = value;
            }
        }

        public string NameCN
        {
            get { return _nameCN; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for NameCN", value, value.ToString());
                _nameCN = value;
            }
        }

        public string NameChinese
        {
            get { return _nameChinese; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for NameChinese", value, value.ToString());
                _nameChinese = value;
            }
        }

        public string Title
        {
            get { return _title; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for Title", value, value.ToString());
                _title = value;
            }
        }

        public string OfficePhone
        {
            get { return _officePhone; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for OfficePhone", value, value.ToString());
                _officePhone = value;
            }
        }

        public string Email
        {
            get { return _email; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());
                _email = value;
            }
        }

        public string Mobile
        {
            get { return _mobile; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Mobile", value, value.ToString());
                _mobile = value;
            }
        }

        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { _isEnabled = value; }
        }

        public bool IsActived
        {
            get { return _isActived; }
            set { _isActived = value; }
        }

        public string NTAccount
        {
            get { return _nTAccount; }
            set
            {
                if (value != null && value.Length > 250)
                    throw new ArgumentOutOfRangeException("Invalid value for NTAccount", value, value.ToString());
                _nTAccount = value;
            }
        }

        public Employee ReportTo
        {
            get { return _reportTo; }
            set { _reportTo = value; }
        }

        public IList ReportToEmployees
        {
            get { return _reportToEmployees; }
            set { _reportToEmployees = value; }
        }

        public Department Department
        {
            get { return _department; }
            set { _department = value; }
        }

        public IList DelegateUserUserRoles
        {
            get
            {
                if (_delegateUserUserRoles == null)
                {
                    _delegateUserUserRoles = new ArrayList();
                }
                return _delegateUserUserRoles;
            }
            set { _delegateUserUserRoles = value; }
        }

        public IList UserRoles
        {
            get
            {
                if (_userRoles == null)
                {
                    _userRoles = new ArrayList();
                }
                return _userRoles;
            }
            set { _userRoles = value; }
        }

        public IList Agreements
        {
            get
            {
                if (_agreements == null)
                {
                    _agreements = new ArrayList();
                }
                return _agreements;
            }
            set { _agreements = value; }
        }

        public IList EmployeeIdALAttendees
        {
            get
            {
                if (_employeeIdALAttendees == null)
                {
                    _employeeIdALAttendees = new ArrayList();
                }
                return _employeeIdALAttendees;
            }
            set { _employeeIdALAttendees = value; }
        }

        public IList OperationLogs
        {
            get
            {
                if (_operationLogs == null)
                {
                    _operationLogs = new ArrayList();
                }
                return _operationLogs;
            }
            set { _operationLogs = value; }
        }

        public IList RequesterNoApplications
        {
            get
            {
                if (_requesterNoApplications == null)
                {
                    _requesterNoApplications = new ArrayList();
                }
                return _requesterNoApplications;
            }
            set { _requesterNoApplications = value; }
        }

        public IList SomeoneElseNoApplications
        {
            get
            {
                if (_someoneElseNoApplications == null)
                {
                    _someoneElseNoApplications = new ArrayList();
                }
                return _someoneElseNoApplications;
            }
            set { _someoneElseNoApplications = value; }
        }

        public IList AdvancedSearches
        {
            get
            {
                if (_advancedSearches == null)
                {
                    _advancedSearches = new ArrayList();
                }
                return _advancedSearches;
            }
            set { _advancedSearches = value; }
        }

        public IList ActionOwnerActionPoints
        {
            get
            {
                if (_actionOwnerActionPoints == null)
                {
                    _actionOwnerActionPoints = new ArrayList();
                }
                return _actionOwnerActionPoints;
            }
            set { _actionOwnerActionPoints = value; }
        }

        public IList MyBackupActionLogs
        {
            get
            {
                if (_myBackupActionLogs == null)
                {
                    _myBackupActionLogs = new ArrayList();
                }
                return _myBackupActionLogs;
            }
            set { _myBackupActionLogs = value; }
        }

        public IList FlowMembers
        {
            get
            {
                if (_flowMembers == null)
                {
                    _flowMembers = new ArrayList();
                }
                return _flowMembers;
            }
            set { _flowMembers = value; }
        }

        public IList APPartners
        {
            get
            {
                if (_aPPartners == null)
                {
                    _aPPartners = new ArrayList();
                }
                return _aPPartners;
            }
            set { _aPPartners = value; }
        }

        public IList DepartmentHeadDepartments
        {
            get
            {
                if (_departmentHeadDepartments == null)
                {
                    _departmentHeadDepartments = new ArrayList();
                }
                return _departmentHeadDepartments;
            }
            set { _departmentHeadDepartments = value; }
        }

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public int CompareTo(object obj)
        {
            if (!(obj is Employee))
                throw new InvalidCastException("This object is not of type Employee");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((Employee)obj).Id);
                    break;
                case "NameEN":
                    relativeValue = (this.NameEN != null) ? this.NameEN.CompareTo(((Employee)obj).NameEN) : -1;
                    break;
                case "NameCN":
                    relativeValue = (this.NameCN != null) ? this.NameCN.CompareTo(((Employee)obj).NameCN) : -1;
                    break;
                case "NameChinese":
                    relativeValue = (this.NameChinese != null) ? this.NameChinese.CompareTo(((Employee)obj).NameChinese) : -1;
                    break;
                case "Title":
                    relativeValue = (this.Title != null) ? this.Title.CompareTo(((Employee)obj).Title) : -1;
                    break;
                case "OfficePhone":
                    relativeValue = (this.OfficePhone != null) ? this.OfficePhone.CompareTo(((Employee)obj).OfficePhone) : -1;
                    break;
                case "Email":
                    relativeValue = (this.Email != null) ? this.Email.CompareTo(((Employee)obj).Email) : -1;
                    break;
                case "Mobile":
                    relativeValue = (this.Mobile != null) ? this.Mobile.CompareTo(((Employee)obj).Mobile) : -1;
                    break;
                case "IsEnabled":
                    relativeValue = (this.IsEnabled != Convert.ToBoolean(null)) ? this.IsEnabled.CompareTo(((Employee)obj).IsEnabled) : -1;
                    break;
                case "IsActived":
                    relativeValue = (this.IsActived != Convert.ToBoolean(null)) ? this.IsActived.CompareTo(((Employee)obj).IsActived) : -1;
                    break;
                case "NTAccount":
                    relativeValue = (this.NTAccount != null) ? this.NTAccount.CompareTo(((Employee)obj).NTAccount) : -1;
                    break;
                default:
                    goto case "Id";
            }
            if (Employee.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
